class Solution
{
public:
    int minFlipsMonoIncr(string s)
    {
        int flipCount = 0;
        for (char c : s)
        {
            if (c == '0')
            {
                ++flipCount;
            }
        }
        int minFlipCount = flipCount;
        for (char c : s)
        {
            if (c == '0')
            {
                --flipCount;
            }
            else
            {
                ++flipCount;
            }
            minFlipCount = min(minFlipCount, flipCount);
        }
        return minFlipCount;
    }
};